package view.interfaces;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.Timer;
import javax.swing.border.EmptyBorder;

public class telaPrincipal extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */

	public static void main(String[] args) {

		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					telaPrincipal frame = new telaPrincipal();
					frame.setExtendedState(frame.getExtendedState()
							| JFrame.MAXIMIZED_BOTH);
					frame.setVisible(true);

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */

	private static final long serialVersionUID = 1L;

	private static final DateFormat FORMATO = new SimpleDateFormat(
			"dd/MM/yy - HH:mm:ss");
	private JButton btnTrocarUsurio;
	private JTextField txtByDesenvolvidoPor;
	private JTextField txtOl;

	public void setHora(Date date) {
		setTitle("Pizzaria Di Nonno " + FORMATO.format(date));
	}

	private class ClockAction implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			setHora(new Date());
		}

	}

	public telaPrincipal() {

		Timer t = new Timer(1000, new ClockAction());
		t.setInitialDelay(0);
		t.setRepeats(true);
		t.start();

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 810, 476);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);

		JPanel panel = new JPanel();
		panel.setBorder(BorderFactory.createLineBorder(Color.darkGray, 1));

		btnTrocarUsurio = new JButton("Trocar Usu\u00E1rio");
		btnTrocarUsurio.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new telaLogin().setVisible(true);
				setVisible(false);
			}
		});
		btnTrocarUsurio.setFont(new Font("Tahoma", Font.BOLD, 11));
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(
				Alignment.LEADING).addGroup(
				Alignment.TRAILING,
				gl_panel.createSequentialGroup()
						.addContainerGap(11, Short.MAX_VALUE)
						.addComponent(btnTrocarUsurio).addGap(8)));
		gl_panel.setVerticalGroup(gl_panel.createParallelGroup(
				Alignment.TRAILING).addGroup(
				Alignment.LEADING,
				gl_panel.createSequentialGroup()
						.addContainerGap()
						.addComponent(btnTrocarUsurio)
						.addContainerGap(GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));
		panel.setLayout(gl_panel);

		JPanel panel_1 = new JPanel();

		JPanel panel_2 = new JPanel();

		JLabel lblNewLabel_1 = new JLabel("Pizzaria Di Nonno");
		lblNewLabel_1
				.setIcon(new ImageIcon(
						"C:\\Users\\Michael\\Documents\\Faculdade\\Plano de Ensino - Disciplina Projeto Interativo IV\\Projeto Pizzaria\\Pizzaria\\src\\tumblr_lln52xMpNv1qab04f.gif"));
		lblNewLabel_1.setForeground(Color.RED);
		lblNewLabel_1.setFont(new Font("Traditional Arabic", Font.BOLD, 20));
		lblNewLabel_1.setVerticalAlignment(SwingConstants.TOP);

		JPanel panel_3 = new JPanel();
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane
				.setHorizontalGroup(gl_contentPane
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_contentPane
										.createSequentialGroup()
										.addComponent(lblNewLabel_1,
												GroupLayout.PREFERRED_SIZE,
												338, GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												ComponentPlacement.RELATED,
												300, Short.MAX_VALUE)
										.addComponent(panel,
												GroupLayout.PREFERRED_SIZE,
												136, GroupLayout.PREFERRED_SIZE)
										.addContainerGap())
						.addGroup(
								gl_contentPane
										.createSequentialGroup()
										.addGap(3)
										.addGroup(
												gl_contentPane
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																panel_3,
																GroupLayout.DEFAULT_SIZE,
																781,
																Short.MAX_VALUE)
														.addComponent(
																panel_2,
																GroupLayout.DEFAULT_SIZE,
																781,
																Short.MAX_VALUE)))
						.addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 784,
								Short.MAX_VALUE));
		gl_contentPane
				.setVerticalGroup(gl_contentPane
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_contentPane
										.createSequentialGroup()
										.addGroup(
												gl_contentPane
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																lblNewLabel_1)
														.addGroup(
																gl_contentPane
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				panel,
																				GroupLayout.PREFERRED_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.PREFERRED_SIZE)))
										.addPreferredGap(
												ComponentPlacement.UNRELATED)
										.addComponent(panel_2,
												GroupLayout.PREFERRED_SIZE, 48,
												GroupLayout.PREFERRED_SIZE)
										.addGap(8)
										.addComponent(panel_3,
												GroupLayout.DEFAULT_SIZE,
												GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addGap(11)
										.addComponent(panel_1,
												GroupLayout.PREFERRED_SIZE, 25,
												GroupLayout.PREFERRED_SIZE)
										.addContainerGap()));

		JButton btnNewButton = new JButton("Pizzaiolo");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				telaPizzaiolo pizzaiolo = new telaPizzaiolo();
				pizzaiolo.setVisible(true);
				pizzaiolo.listarAndamento();

				setVisible(false);
			}
		});

		JButton btnNewButton_1 = new JButton("Administrador");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new telaAdministrador().setVisible(true);
				setVisible(false);
			}
		});

		JButton btnNewButton_2 = new JButton("Atendente");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new telaAtendente().setVisible(true);
				setVisible(false);
			}
		});

		JButton btnNewButton_3 = new JButton("SAIR");
		btnNewButton_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});
		btnNewButton_3.setFont(new Font("Tahoma", Font.BOLD, 11));

		GroupLayout gl_panel_3 = new GroupLayout(panel_3);
		gl_panel_3.setHorizontalGroup(gl_panel_3
				.createParallelGroup(Alignment.LEADING)
				.addGroup(
						gl_panel_3
								.createSequentialGroup()
								.addGap(189)
								.addComponent(btnNewButton_1,
										GroupLayout.DEFAULT_SIZE, 131,
										Short.MAX_VALUE)
								.addPreferredGap(ComponentPlacement.RELATED)
								.addComponent(btnNewButton_2,
										GroupLayout.DEFAULT_SIZE, 131,
										Short.MAX_VALUE)
								.addPreferredGap(ComponentPlacement.RELATED)
								.addComponent(btnNewButton,
										GroupLayout.DEFAULT_SIZE, 131,
										Short.MAX_VALUE).addGap(187))
				.addGroup(
						gl_panel_3
								.createSequentialGroup()
								.addGap(360)
								.addComponent(btnNewButton_3,
										GroupLayout.DEFAULT_SIZE,
										GroupLayout.DEFAULT_SIZE,
										Short.MAX_VALUE).addGap(360)));
		gl_panel_3
				.setVerticalGroup(gl_panel_3
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_panel_3
										.createSequentialGroup()
										.addGap(110)
										.addGroup(
												gl_panel_3
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																btnNewButton)
														.addGroup(
																gl_panel_3
																		.createParallelGroup(
																				Alignment.BASELINE)
																		.addComponent(
																				btnNewButton_2,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addComponent(
																				btnNewButton_1,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)))
										.addGap(76)
										.addComponent(btnNewButton_3)
										.addContainerGap()));
		panel_3.setLayout(gl_panel_3);

		txtOl = new JTextField();
		txtOl.setFont(new Font("Vijaya", Font.BOLD, 20));
		txtOl.setHorizontalAlignment(SwingConstants.CENTER);
		txtOl.setText("Ol\u00E1! Seja bem vindo ao sistema de controle de Pizzaria, clique abaixo no m\u00F3dulo ao qual tem permiss\u00E3o para utilizar.");
		txtOl.setColumns(10);
		GroupLayout gl_panel_2 = new GroupLayout(panel_2);
		gl_panel_2.setHorizontalGroup(gl_panel_2.createParallelGroup(
				Alignment.LEADING).addGroup(
				gl_panel_2
						.createSequentialGroup()
						.addComponent(txtOl, GroupLayout.DEFAULT_SIZE, 789,
								Short.MAX_VALUE).addContainerGap()));
		gl_panel_2.setVerticalGroup(gl_panel_2.createParallelGroup(
				Alignment.LEADING).addGroup(
				gl_panel_2
						.createSequentialGroup()
						.addGap(5)
						.addComponent(txtOl, GroupLayout.DEFAULT_SIZE, 115,
								Short.MAX_VALUE).addContainerGap()));
		panel_2.setLayout(gl_panel_2);

		txtByDesenvolvidoPor = new JTextField();
		txtByDesenvolvidoPor.setHorizontalAlignment(SwingConstants.CENTER);
		txtByDesenvolvidoPor.setFont(new Font("Tahoma",
				Font.BOLD | Font.ITALIC, 12));
		txtByDesenvolvidoPor
				.setText("BY: Desenvolvido por Centro Universit\u00E1rio Senac - Turma 4\u00BA BSI - 2013 - Arthur / Daniel / Julien / Mayk / Michael / Renan");
		txtByDesenvolvidoPor.setColumns(10);
		GroupLayout gl_panel_1 = new GroupLayout(panel_1);
		gl_panel_1.setHorizontalGroup(gl_panel_1.createParallelGroup(
				Alignment.LEADING).addGroup(
				Alignment.TRAILING,
				gl_panel_1
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(txtByDesenvolvidoPor,
								GroupLayout.DEFAULT_SIZE, 782, Short.MAX_VALUE)
						.addContainerGap()));
		gl_panel_1.setVerticalGroup(gl_panel_1.createParallelGroup(
				Alignment.LEADING).addGroup(
				gl_panel_1
						.createSequentialGroup()
						.addComponent(txtByDesenvolvidoPor,
								GroupLayout.PREFERRED_SIZE,
								GroupLayout.DEFAULT_SIZE,
								GroupLayout.PREFERRED_SIZE)
						.addContainerGap(GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));
		panel_1.setLayout(gl_panel_1);
		contentPane.setLayout(gl_contentPane);

	}
}
